package com.ruoyi.management_controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.management_controller.HyperlinkTable.domain.HyperlinkTable;
import com.ruoyi.management_controller.HyperlinkTable.service.IHyperlinkTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 超链接挂载Controller
 * 
 * @author ruoyi
 * @date 2024-07-21
 */
@RestController
@RequestMapping("/HyperlinkTable/HyperlinkTable")
public class HyperlinkTableController extends BaseController
{
    @Autowired
    private IHyperlinkTableService hyperlinkTableService;

    /**
     * 查询超链接挂载列表
     */
    @PreAuthorize("@ss.hasPermi('HyperlinkTable:HyperlinkTable:list')")
    @GetMapping("/list")
    public TableDataInfo list(HyperlinkTable hyperlinkTable)
    {
        startPage();
        List<HyperlinkTable> list = hyperlinkTableService.selectHyperlinkTableList(hyperlinkTable);
        return getDataTable(list);
    }

    /**
     * 导出超链接挂载列表
     */
    @PreAuthorize("@ss.hasPermi('HyperlinkTable:HyperlinkTable:export')")
    @Log(title = "超链接挂载", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HyperlinkTable hyperlinkTable)
    {
        List<HyperlinkTable> list = hyperlinkTableService.selectHyperlinkTableList(hyperlinkTable);
        ExcelUtil<HyperlinkTable> util = new ExcelUtil<HyperlinkTable>(HyperlinkTable.class);
        util.exportExcel(response, list, "超链接挂载数据");
    }

    /**
     * 获取超链接挂载详细信息
     */
    @PreAuthorize("@ss.hasPermi('HyperlinkTable:HyperlinkTable:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hyperlinkTableService.selectHyperlinkTableById(id));
    }

    /**
     * 新增超链接挂载
     */
    @PreAuthorize("@ss.hasPermi('HyperlinkTable:HyperlinkTable:add')")
    @Log(title = "超链接挂载", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HyperlinkTable hyperlinkTable)
    {
        return toAjax(hyperlinkTableService.insertHyperlinkTable(hyperlinkTable));
    }

    /**
     * 修改超链接挂载
     */
    @PreAuthorize("@ss.hasPermi('HyperlinkTable:HyperlinkTable:edit')")
    @Log(title = "超链接挂载", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HyperlinkTable hyperlinkTable)
    {
        return toAjax(hyperlinkTableService.updateHyperlinkTable(hyperlinkTable));
    }

    /**
     * 删除超链接挂载
     */
    @PreAuthorize("@ss.hasPermi('HyperlinkTable:HyperlinkTable:remove')")
    @Log(title = "超链接挂载", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hyperlinkTableService.deleteHyperlinkTableByIds(ids));
    }
}
